#ifndef PRESCRIPTIONVIEWWIDGET_H
#define PRESCRIPTIONVIEWWIDGET_H

#include <QWidget>
#include <QJsonObject>
#include <QJsonArray>
#include "../../../Common/models.h"
#include "../../../Common/protocol.h"

namespace Ui {
class PrescriptionViewWidget;
}

class PrescriptionViewWidget : public QWidget {
    Q_OBJECT
    
public:
    explicit PrescriptionViewWidget(const Patient& patient, QWidget *parent = nullptr);
    ~PrescriptionViewWidget();
    
private slots:
    void on_refreshButton_clicked();
    void onMessageReceived(MessageType type, const QJsonObject& data);
    void onViewDetailClicked();
    void onChatWithDoctorClicked();
    
private:
    void loadPrescriptions();
    void updatePrescriptionTable(const QJsonArray& prescriptions);
    
    Ui::PrescriptionViewWidget *ui;
    Patient m_patient;
    QJsonArray m_prescriptions; // 存储处方数据
};

#endif // PRESCRIPTIONVIEWWIDGET_H

